package com.redstar.study;

import java.util.List;


import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;

public class FanMenuAdapter extends BaseAdapter implements OnClickListener {
	private Context context;
	private String[] listOfOptions;
	
	public FanMenuAdapter(Context context, String[] fanOptions) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.listOfOptions = fanOptions;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return listOfOptions.length;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup viewGroup) {
		Intent i;
		// TODO Auto-generated method stub
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.fan_item, null);
        }
        
        TextView Tv = (TextView) convertView.findViewById(R.id.fanItemTextiew);
        Button Btn = (Button)  convertView.findViewById(R.id.fanItemSettingsButton);
        
		switch (position) {
		case 0:
			Tv.setText("Practice");
			Tv.setOnTouchListener(new OnTouchListener(){

				public boolean onTouch(View arg0, MotionEvent arg1) {
					// TODO Auto-generated method stub
					context.startActivity(new Intent(context, Practice.class));
					return false;
				}
				
			});
			Btn.setVisibility(View.VISIBLE);
			Btn.setOnClickListener(new OnClickListener(){

				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					context.startActivity(new Intent(context, PracticePreferences.class));
				}
				
			});
			break;
		case 1:
			Tv.setText("Quiz");
			Tv.setOnTouchListener(new OnTouchListener(){

				public boolean onTouch(View arg0, MotionEvent arg1) {
					// TODO Auto-generated method stub
					context.startActivity(new Intent(context, Quiz.class));
					return false;
				}
				
			});
			Btn.setVisibility(View.VISIBLE);
			Btn.setOnClickListener(new OnClickListener(){

				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					context.startActivity(new Intent(context, QuizPreferences.class));
				}
				
			});
			break;
		case 2:
			Tv.setText("Dictionary");
			Tv.setOnTouchListener(new OnTouchListener(){

				public boolean onTouch(View arg0, MotionEvent arg1) {
					// TODO Auto-generated method stub
					context.startActivity(new Intent(context, Dictionary.class));
					return false;
				}
				
			});
			Btn.setVisibility(View.INVISIBLE);
			break;
		default:
			break;
		}
       
       // tvKanji.setText(entry.getKanji());
      
		return convertView;
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub

	}

}
